﻿using System.ComponentModel;
using System.Reflection;

namespace ORS.OrderRobot.Helper
{
	public class EnumHelper
	{
        /// <summary>
        /// 获取枚举项上的描述
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string GetEnumDescription(Enum value)
        {
            FieldInfo field = value.GetType().GetField(value.ToString());
            DescriptionAttribute attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;

            return attribute == null ? value.ToString() : attribute.Description;
        }
    }
}

